home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1997 #2 / Amiga Plus Extra 1997 #2.iso / pd / misc / envwrd41 / source / warpspell / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-16  |  2.7 KB  |  106 lines

  1. #include "defs.h"
  2.  
  3. /// "Prototypes"
  4.  
  5. Prototype BOOL InitC(void);
  6.  
  7. ///
  8. /// "Init"
  9.  
  10. /* ----------------------------------- InitC -----------------------------------
  11.  
  12.  Library startup code (C entry point).
  13.  
  14. */
  15.  
  16. __geta4 BOOL
  17. InitC(void)
  18. {
  19.     UBYTE options[255];
  20.     UWORD ascii;
  21.  
  22.     InitSemaphore(&ISpellSemaphore);
  23.  
  24.     // valid characters: A-Z, a-z and national characters (äöü...)
  25.  
  26.     for (ascii = 0; ascii < 256; ++ascii)
  27.  
  28.         IsLetter[ascii] = ((ascii >= 'A') && (ascii <= 'Z')) || ((ascii >= 'a') && (ascii <= 'z')) || ((ascii >= 192) && (ascii != 215) && (ascii != 247));
  29.  
  30.     QuickCheck = TRUE;
  31.  
  32.     // read options
  33.  
  34.     if (GetVar("WORDS.prefs", options, sizeof(options), GVF_GLOBAL_ONLY) != -1) {
  35.  
  36.         struct RDArgs *rdArgs, *args;
  37.  
  38.         if (rdArgs = AllocDosObject(DOS_RDARGS, NULL)) {
  39.  
  40.             ULONG argArray[] = { 0, 0, 0, 0, 0 };
  41.  
  42.             // make LF-terminated copy of options string (required by dos/readArgs):
  43.  
  44.             strcat(options, "\12");
  45.  
  46.             rdArgs->RDA_Source.CS_Buffer = options;
  47.             rdArgs->RDA_Source.CS_Length = strlen(options);
  48.             rdArgs->RDA_Source.CS_CurChr = 0;
  49.             rdArgs->RDA_DAList           = 0;
  50.             rdArgs->RDA_Buffer           = NULL;
  51.  
  52.             if (args = ReadArgs("LANGUAGE/K,QUICKCHECK/K,BOUNDARYCHARS/K,BEEP/N,ARGS/F", argArray, rdArgs)) {
  53.  
  54.                 if (argArray[1]) {                   // QUICKCHECK/S
  55.  
  56.                     if (stricmp((UBYTE *)argArray[1], "TRUE"))
  57.                         QuickCheck = FALSE;
  58.                     else
  59.                         QuickCheck = TRUE;
  60.                 }
  61.  
  62.                 if (argArray[2]) {                   // BOUNDARYCHARS/K
  63.  
  64.                     // boundary characters (e.g. ') are either letter (if next character is a letter) or space
  65.  
  66.                     UBYTE *isBoundary = (UBYTE *)argArray[2];
  67.  
  68.                     while (*isBoundary)
  69.  
  70.                         IsBoundary[(UWORD)*isBoundary++] = TRUE;
  71.                 }
  72.  
  73.                 if (argArray[4]) {                   // ARGS/F
  74.  
  75.                     UBYTE *isChar;
  76.  
  77.                     // additional characters to be considered as "letter" ? Syntax: -w "..."
  78.  
  79.                     if (isChar = strstr((UBYTE *)argArray[4], "-w ")) {
  80.  
  81.                         while (*isChar) {
  82.  
  83.                             if (*isChar++ == 34) {
  84.  
  85.                                 while (*isChar && (*isChar != 34))
  86.  
  87.                                     IsLetter[(UWORD)*isChar++] = TRUE;
  88.  
  89.                                 break;
  90.                             }
  91.                         }
  92.                     }
  93.                 }
  94.  
  95.                 FreeArgs(args);
  96.             }
  97.  
  98.             FreeDosObject(DOS_RDARGS, rdArgs);
  99.         }
  100.     }
  101.  
  102.     return(TRUE);
  103. }
  104.  
  105. ///
  106.